package IC;

public class Utils 
{
	public static void DrawArrow(int pos)
    {
    	for (int l = 0; l < pos - 1; l++)
			System.out.print(" ");
		
		System.out.println("/_\\");
		for (int l = 0; l < pos; l++)
			System.out.print("-");
		System.out.println("|");
    }
    
    public static String LineFromFile(String file, int line) throws java.io.IOException
    {
    	java.io.LineNumberReader lineReader = new java.io.LineNumberReader(new java.io.FileReader(file));
		while(lineReader.getLineNumber() < line)				
			lineReader.read();
		String temp = lineReader.readLine();
		lineReader.close();
		return temp;
    }
    
    public static java.io.Reader GetReader(String fileName)
	{
		try
		{
			return new java.io.FileReader(fileName);
		}
		catch (java.io.FileNotFoundException e)
		{
			return null;
		}
	}
    
    public static java.io.Writer GetWriter(String fileName)
    {
    	try
    	{
    		return new java.io.FileWriter(fileName);
    	}
    	catch (java.io.IOException e)
    	{
    		return null;
    	}
    }
    
    public static boolean CloseReader(java.io.Reader reader)
    {
    	try 
    	{
    		reader.close();
    		return false;
    	} 
    	catch (java.lang.Exception e) { return false; }
    }
    
    public static String TrimLast(String inp, int num)
    {
    	if (inp.length() == 0)
    		return inp;
    	
    	return inp.substring(0, inp.length() - num);
    }
}
